<!-- php:$title = ($cate_rs && $cate_rs.id != $page_rs.cate) ? '发布主题_'.$cate_rs.title.'_'.$page_rs.title : '发布主题_'.$page_rs.title -->
<!-- include tpl=header title=$title menutitle=$page_rs.title -->
<!-- include file=bbs_post -->
<script type="text/javascript">
$(document).ready(function(){
	var is_vcode = '<!-- if $is_vcode -->true<!-- else -->false<!-- /if -->';
	$("#post_submit").submit(function(){
		var title = $("#title").val();
		if(!title){
			$.dialog.alert('新贴主题不能为空');
			return false;
		}
		var cate_id = $("#cate_id").val();
		if(!cate_id){
			$.dialog.alert('没有指定分类');
			return false;
		}
		if(is_vcode == 'true'){
			var chkcode = $("#_chkcode").val();
			if(!chkcode){
				$.dialog.alert('验证码不能为空',function(){
					$("#_vcode").phpok_vcode();
				});
				return false;
			}
		}
		var content = UE.getEditor('content').getContentTxt();
		if(!content){
			$.dialog.alert('内容不能为空');
			return false;
		}
		$(this).ajaxSubmit({
			'url':api_url('post','ok'),
			'type':'post',
			'dataType':'json',
			'success':function(rs){
				if(!rs.status){
					$.dialog.alert(rs.info,function(){
						$("#_vcode").phpok_vcode();
						$("#_chkcode").val('');
					});
					return false;
				}
				$.dialog.alert('您的信息已发布，感谢您的提交',function(){
					$.phpok.go("{$_back}");
				});
			}
		});
		return false;
	});
});
</script>
<section class="container"><div class="mt-3"><!-- include tpl=block/breadcrumb leader=$leader --></div></section>

<section class="container">
	<div class="card">
		<div class="card-header">发新贴</div>
		<div class="card-body">
			<form method="post" id="post_submit" class="am-form">
			<input type="hidden" name="id" id="id" value="{$page_rs.identifier}" />
			<!-- if $cate_rs -->
			<input type="hidden" name="cate_id" id="cate_id" value="{$cate_rs.id}" />
			<!-- /if -->
			<div class="row form-group">
				<label class="col-sm-2" for="title">主题名称</label>
				<div class="col-sm-10"><input type="text" name="title" id="title" /></div>
			</div>
			<!-- if $catelist && !$cate_rs -->
			<div class="row form-group">
				<label class="col-sm-2" for="title">分类</label>
				<div class="col-sm-10">
					<select name="cate_id" id="cate_id">
						<option value="">请选择分类……</option>
						<!-- loop from=$catelist key=$key value=$value id=$tmpid -->
						<option value="{$value.id}"{if $cate_rs.id == $value.id} selected{/if}>{$value._space}{$value.title}</option>
						<!-- /loop -->
					</select>
				</div>
			</div>
			<!-- /if -->
			<!-- fields pid=$page_rs.id fields_format=1 -->
			<!-- loop from=$list key=$key value=$value -->
			<div class="row form-group">
				<label class="col-sm-2" for="{$value.identifier}">{$value.title}</label>
				<div class="col-sm-10">{$value.html}</div>
			</div>
			<!-- /loop -->
			<!-- if $is_vcode -->
			<div class="row form-group">
				<label class="col-sm-2" for="_chkcode">验证码：</label>
				<div class="col-sm-4"><input type="text" name="_chkcode" id="_chkcode" class="vcode" /></div>
				<div class="col-sm-6"><img src="" border="0" align="absmiddle" id="update_vcode" class="hand"></div>
				<script type="text/javascript">
				$(document).ready(function(){
					$("#update_vcode").phpok_vcode();
					//更新点击时操作
					$("#update_vcode").click(function(){
						$(this).phpok_vcode();
					});
				});
				</script>
			</div>
			<!-- /if -->
			<div class="row form-group">
				<div class="col-sm-2">&nbsp;</div>
				<div class="col-sm-5"><input type="submit" value=" 提交 " class="btn btn-primary btn-lg" /></div>
				<div class="col-sm-5 text-right">
					<a href="{url ctrl=$page_rs.identifier func=$cate_rs.identifier/}" title="返回列表">返回列表</a>
				</div>
			</div>
			
			</form>
		</div>
	</div>
</section>

<!-- include tpl=footer -->